package com.pacy.pacybaseproject.activitys;

import android.graphics.Color;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.fragment.app.Fragment;

import com.blankj.utilcode.util.FragmentUtils;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.fondesa.recyclerviewdivider.DividerBuilder;
import com.gyf.immersionbar.ImmersionBar;
import com.pacy.pacybaseproject.BR;
import com.pacy.pacybaseproject.R;
import com.pacy.pacybaseproject.activitys.routing.RoutingBusFragment;
import com.pacy.pacybaseproject.activitys.routing.RoutingTaxiFragment;
import com.pacy.pacybaseproject.activitys.routing.RoutingWalkFragment;
import com.pacy.pacybaseproject.base.BaseXActivity;
import com.pacy.pacybaseproject.beans.TabBean;
import com.pacy.pacybaseproject.databinding.ActivityRoutingBinding;
import com.pacy.pacybaseproject.databinding.ActivityRoutingSearchBinding;
import com.pacy.pacybaseproject.viewmodels.RoutingSearchViewModel;
import com.pacy.pacybaseproject.viewmodels.RoutingViewModel;
import com.xuexiang.xui.utils.StatusBarUtils;

import java.util.ArrayList;
import java.util.List;

import me.goldze.mvvmhabit.utils.KLog;

/**
 * 路线规划
 */
public class RoutingSearchActivity extends BaseXActivity<ActivityRoutingSearchBinding, RoutingSearchViewModel> {
    private ArrayList<CustomTabEntity> tabs = new ArrayList<>();



    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_routing_search;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        ImmersionBar.with(this).statusBarDarkFont(true).init();
        setStateLayout(binding.state);
        initTab();
        LinearLayout.LayoutParams params=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, StatusBarUtils.getStatusBarHeight(RoutingSearchActivity.this));
        binding.view.setLayoutParams(params);
        viewModel.mBaiduMap=binding.mapView.getMap();
        if (binding.recyclerView.getItemDecorationCount() == 0) {
            new DividerBuilder(RoutingSearchActivity.this)
                    .size(15, TypedValue.COMPLEX_UNIT_DIP)
                    .color(Color.TRANSPARENT)
                    .showFirstDivider()
                    .showLastDivider()
                    .build().addTo(binding.recyclerView);
        }
    }

    private void initTab(){
//        tabs.add(new TabBean("智能推荐",R.drawable.gongjiao_true,R.drawable.gongjiao_false));
//        tabs.add(new TabBean("公交地铁",R.drawable.gongjiao_true,R.drawable.gongjiao_false));
//        tabs.add(new TabBean("驾车",R.drawable.taxi_true,R.drawable.taxi_false));
//        tabs.add(new TabBean("步行",R.drawable.buxing_true,R.drawable.buxing_false));
        tabs.add(new TabBean("智能推荐"));
        tabs.add(new TabBean("公交地铁"));
        tabs.add(new TabBean("驾车"));
        tabs.add(new TabBean("骑行"));
        binding.tabLayout.setTabData(tabs);
        binding.tabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                if(position==0||position==1){
                    viewModel.showMap.setValue(false);
                }else{
                    viewModel.showMap.setValue(true);
                }
                viewModel.routingSearch(position);
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
        binding.tabLayout.setCurrentTab(0);
    }
}